home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 2 / Amiga Tools 2.iso / net / parnet-3.2 / extras / parpc / amigafiles / sources / wakeup.asm < prev   
Assembly Source File  |  1995-03-09  |  3KB  |  176 lines

  1.  
  2.         ;   WAKEUP.ASM
  3.         ;
  4.  
  5.         section __MERGED,DATA
  6.  
  7.         xdef    _VTask
  8.         xdef    _VMask
  9.  
  10. _VTask        dc.l    0
  11. _VMask        dc.l    0
  12.  
  13. MiscRes     dc.l    0
  14. CIARes        dc.l    0
  15. CIBRes        dc.l    0
  16. MiscName    dc.b    'misc.resource',0
  17. CIAName     dc.b    'ciaa.resource',0
  18. CIBName     dc.b    'ciab.resource',0
  19.  
  20.         ;   ICR interrupt
  21.  
  22.         section text,code
  23.  
  24.         xref    _SysBase
  25.         xref    _LVOSignal
  26.         xref    _LVOOpenResource
  27.         xdef    _VInt
  28.  
  29. _VInt:        move.l    _SysBase,A6
  30.         move.l    _VTask,A1
  31.         move.l    _VMask,D0
  32.         jsr    _LVOSignal(A6)
  33.         moveq.l #1,D0        ; clear interrupt.
  34.         rts
  35.  
  36.         ;   VAddICRVector(cia#, intnum, int)
  37.         ;   VRemICRVector(cia#, intnum, int)
  38.         ;
  39.         ;   cia# : 0 = ciaa, 1 = ciab
  40.  
  41.         xdef    _VAddICRVector
  42.         xdef    _VRemICRVector
  43.         xdef    _VSetICR
  44.         xdef    _VAbleICRA        ; enable/disable ints for CIAA.
  45.         xref    _LVOAbleICR
  46.         xref    _LVORemICRVector
  47.         xref    _LVOAddICRVector
  48.         xref    _LVOSetICR
  49.  
  50. _VAbleICRA:    move.l    A6,-(sp)
  51.         move.l    CIARes,D0
  52.         bne    .vaica10
  53.         bsr    GetCIAResource        ; D0 = 0, get resource for ciaa
  54. .vaica10    move.l    D0,A6            ; assume it works <sigh>.
  55.         move.l    4+4(sp),D0          ; D0 = mask
  56.         jsr    _LVOAbleICR(A6)
  57.         move.l    (sp)+,A6
  58.         rts
  59.  
  60. _VSetICR:
  61.         move.l    A6,-(sp)
  62.         move.l    4+4(sp),D0
  63.         bsr    GetCIAResource
  64.         tst.l    D0
  65.         beq    .badres
  66.         move.l    4+8(sp),D0      ; mask
  67.         jsr    _LVOSetICR(A6)
  68.         move.l    (sp)+,A6
  69.         rts
  70.  
  71. _VAddICRVector:
  72.         move.l    A6,-(sp)
  73.         move.l    4+4(sp),D0
  74.         bsr    GetCIAResource
  75.         tst.l    D0
  76.         beq    .badres
  77.         move.l    4+8(sp),D0
  78.         move.l    4+12(sp),A1
  79.         jsr    _LVOAddICRVector(A6)
  80.         move.l    (sp)+,A6
  81.         rts
  82.  
  83. _VRemICRVector:
  84.         move.l    A6,-(sp)
  85.         move.l    4+4(sp),D0
  86.         bsr    GetCIAResource
  87.         tst.l    D0
  88.         beq    .badres
  89.         move.l    4+8(sp),D0
  90.         move.l    4+12(sp),A1
  91.         jsr    _LVORemICRVector(A6)
  92.         move.l    (sp)+,A6
  93.         rts
  94.  
  95. .badres     moveq.l #-1,D0
  96.         move.l    (sp)+,A6
  97.         rts
  98.  
  99.         ;   Retrieve CIAA (D0 = 0) or CIAB (D0 != 0) resource
  100.  
  101. GetCIAResource:
  102.         move.l    _SysBase,A6
  103.         tst.l    D0
  104.         bne    .gcr100
  105.         move.l    CIARes,D0
  106.         bne    .gcrrts
  107.         lea    CIAName,A1
  108.         jsr    _LVOOpenResource(A6)
  109.         move.l    D0,CIARes
  110.         bra    .gcrrts
  111.  
  112. .gcr100     move.l    CIBRes,D0
  113.         bne    .gcrrts
  114.         lea    CIBName,A1
  115.         jsr    _LVOOpenResource(A6)
  116.         move.l    D0,CIBRes
  117.  
  118. .gcrrts     move.l    D0,A6
  119.         rts
  120.  
  121.  
  122.  ;
  123.  ;  EXEC resource support
  124.  ;                   4(sp)  8(sp)
  125.  ;    AutoAllocMiscResource(resno, value)
  126.  ;        resno:  MR_SERIALPORT, SERIALBITS, PARALLELPORT, PARALLELBITS
  127.  ;        value:  -1 to allocate, 0 to check
  128.  ;
  129.  ;        returns 0 on success
  130.  ;
  131.  ;    AutoFreeMiscResource(resno)
  132.  ;                  4(sp)
  133.  ;        Free a misc resource you allocated
  134.  ;
  135.  ;    No need to open the misc.resource
  136.  
  137.         xdef    _AutoAllocMiscResource
  138.         xdef    _AutoFreeMiscResource
  139.  
  140. _AutoAllocMiscResource:
  141.         move.l    A6,-(sp)
  142.         bsr    OpenMiscResource
  143.         beq    amfail
  144.         move.l    8(sp),D0
  145.         move.l    12(sp),A1
  146.         jsr    -6(A6)
  147.         bra    amret
  148. amfail        moveq.l #-1,D0
  149. amret        move.l    (sp)+,A6
  150.         rts
  151.  
  152. _AutoFreeMiscResource:
  153.         move.l    A6,-(sp)
  154.         bsr    OpenMiscResource
  155.         beq    fmret
  156.         move.l    8(sp),D0
  157.         jsr    -12(A6)
  158. fmret        move.l    (sp)+,A6
  159.         rts
  160.  
  161. OpenMiscResource:
  162.         move.l    MiscRes,D0
  163.         bne    .omr10
  164.         move.l    4,A6
  165.         lea.l    MiscName,A1
  166.         jsr    _LVOOpenResource(A6)
  167. .omr10        move.l    D0,A6
  168.         tst.l    D0
  169.         rts
  170.  
  171.         END
  172.  
  173.  
  174.  
  175.  
  176.